home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / mac / PageMaker 6.5 SDK Mac / SourceCode / PageMakerClassLibrary / LowLevel / PCommand.cpp < prev    next >
C/C++ Source or Header  |  1996-09-05  |  3KB  |  131 lines

  1. /*
  2.  *--- PCommand.cpp --------------------------------------------------------
  3.  * Copyright (c) 1995-96 Adobe Systems Incorporated.  All rights reserved.
  4.  * Created on Thu, Oct 12, 1995 @ 9:54 PM by Paul Ferguson.
  5.  *
  6.  * Description:  For notes about this class, refer to the
  7.  * header file PCommand.h
  8.  *-------------------------------------------------------------------------
  9.  */
  10.  
  11. #include <string.h>
  12.  
  13. #include "PCommand.h"
  14. #include "PRequestBuf.h"
  15.  
  16. PCommand::PCommand()        // Note: This constructor does NOT call DoCommand().
  17. {
  18.  
  19. }
  20.  
  21. /*
  22.  *--- PCommand constructor -------------------------------------
  23.  * For commands with no parameters.
  24.  *--------------------------------------------------------------
  25.  */
  26. PCommand::PCommand(ePMCommand op)
  27. {
  28.     DoCommand(op);
  29. }
  30.  
  31.  
  32. /*
  33.  *--- PCommand constructor -------------------------------------
  34.  * Issue a command that requires a single short integer
  35.  * parameter (for example, the Alignment command).
  36.  *--------------------------------------------------------------
  37.  */
  38. PCommand::PCommand(ePMCommand op, short v)
  39. {
  40.     itsPB->requestData = &v;    
  41.     itsPB->requestSize = sizeof(short);
  42.     itsPB->requestStyle = kXRSPointer;
  43.  
  44.     DoCommand(op);
  45. }
  46.  
  47. /*
  48.  *--- PCommand constructor -------------------------------------
  49.  * Issue a command that requires a single long integer parameter
  50.  * (for example, the SelectID command).
  51.  *--------------------------------------------------------------
  52.  */
  53.  
  54. PCommand::PCommand(ePMCommand op, long v)
  55. {
  56.     itsPB->requestData = (void *) v;
  57.     itsPB->requestSize = sizeof(long);
  58.     itsPB->requestStyle = kXRSValue;
  59.  
  60.     DoCommand(op);
  61. }
  62.  
  63. /*
  64.  *--- PCommand constructor -------------------------------------
  65.  * Issue a command that requires a C string parameter.
  66.  *--------------------------------------------------------------
  67.  */
  68.  
  69. PCommand::PCommand(ePMCommand op, const char * theString)
  70. {
  71.     itsPB->requestData  = theString;
  72.     itsPB->requestSize  = strlen(theString) + 1;
  73.     itsPB->requestStyle = kXRSPointer;
  74.  
  75.     DoCommand(op);
  76. }
  77.  
  78. /*
  79.  *--- PCommand constructor -------------------------------------
  80.  * Issue a command with a formed request parameter buffer.
  81.  *--------------------------------------------------------------
  82.  */
  83.  
  84. PCommand::PCommand(ePMCommand op, void * rawBuf, size_t theLen)
  85. {
  86.     itsPB->requestData  = rawBuf;
  87.     itsPB->requestSize  = theLen;
  88.     itsPB->requestStyle = kXRSPointer;
  89.  
  90.     DoCommand(op);
  91. }
  92.  
  93. /*
  94.  *--- PCommand constructor -------------------------------------
  95.  * Issue a command that has a request buffer with it.
  96.  *--------------------------------------------------------------
  97.  */
  98.  
  99. PCommand::PCommand(ePMCommand op, PRequestBuf& request)
  100. {
  101.     itsPB->requestData  = (const char *) request;
  102.     itsPB->requestSize  = request.Size();
  103.     itsPB->requestStyle = kXRSPointer;
  104.     itsPB->requestUnits = 0;
  105.  
  106.     DoCommand(op);
  107. }
  108.  
  109.  
  110. /*
  111.  *--- DoCommand ------------------------------------------------
  112.  * All commands should clear the reply block before calling.
  113.  *
  114.  * Issue private callback using PCallback.
  115.  *--------------------------------------------------------------
  116.  */
  117.  
  118. void PCommand::DoCommand(ePMCommand op)
  119. {
  120.     itsPB->opCode = op;
  121.  
  122.     itsPB->replyData  = NULL;
  123.     itsPB->replySize  = 0;
  124.     itsPB->replyStyle = kXRSNull;
  125.     itsPB->replyUnits = 0;
  126.     
  127.     CallPageMaker();
  128. }
  129.  
  130. // end of PCommand.cpp
  131.